package com.inspinia.upms.common.model.jwt;

import com.inspinia.base.common.model.NameCodeEnum;

/**
 * code and msg
 * Created by Administrator on 2018/11/13.
 */
public enum CodeAndMsgEnum implements NameCodeEnum {
    SUCCESS(100200, "请求受理成功！"),
    INFO(100204, "请求受理成功，响应数据为空！"),
    UNAUTHENTIC(100401, "无权访问，当前是匿名访问，请先登录！"),
    UNAUTHORIZED(100403, "无权访问，当前帐号权限不足！"),
    NOTFOUND(100404, "服务器未找到资源"),
    ERROR(100500, "服务器发生错误！");


    private final int code;
    private final String name;

    CodeAndMsgEnum(int code, String name){
        this.code=code;
        this.name=name;
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getName() {
        return name;
    }

    public static CodeAndMsgEnum valueOf(int code) {
        for (CodeAndMsgEnum type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        return null;
    }

    public static CodeAndMsgEnum nameOf(String name){
        for (CodeAndMsgEnum type : values()) {
            if (type.name.equals(name)) {
                return type;
            }
        }
        return null;
    }
}
